import SipCall from "../utils/sipCall";
import React from "react";

interface StunConfig {
    type: StunType;
    host: string;
    username: string;
    password: string;
}
type StunType = "turn" | "stun";


export interface SipConfig {
    host: string;
    port: string;
    domain?: string;
    proto?: boolean;
    extNo: string;
    extPwd: string;
    checkMic?: boolean;
    stun?: StunConfig;
    autoRegister?: boolean;
    debug?: boolean;
    stateEventListener?: Function;
}

//呼叫方向:outbound呼出;inbound:呼入
type CallDirection = "outbound" | "inbound"
export interface StateListenerMessage {
    msg?: string;
    localAgent?: String;
    direction?: CallDirection; //呼叫方向
    otherLegNumber?: String;
    callId?: String;

    latencyTime?: number | undefined //网络延迟(ms)
    upLossRate?: number | undefined //上行-丢包率
    downLossRate?: number | undefined //下行-丢包率
}

export interface CallEndEvent {
    originator: string;//local,remote
    cause: string;
    code: number;
    answered: boolean;
}

export interface LatencyStat {
    latencyTime: number,
    upLossRate: number,
    upAudioLevel: number,//上行-outbound-音量
    downLossRate: number,
    downAudioLevel: number,//下行-inbound-音量
}

// sip联络中心Props
export interface ContactCenterProps {
    options: SipConfig;
    onRegister:(value: SipCall) => void;
    ref?:React.ForwardedRef<any>
}
